<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商品信息编辑--${site.name}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="${site.description}"/>
    <meta name="keywords" content="${site.keywords}"/>
    <meta name="author" content="${site.author}"/>
    <link rel="icon" href="${site.logo}">
    <link rel="stylesheet" href="${base}/static/layui/css/layui.css" media="all" />
    <style type="text/css">
        .layui-form-item .layui-inline{ width:33.333%; float:left; margin-right:0; }
        @media(max-width:1240px){
            .layui-form-item .layui-inline{ width:100%; float:none; }
        }
        .layui-form-item .role-box {
            position: relative;
        }
        .layui-form-item .role-box .jq-role-inline {
            height: 100%;
            overflow: auto;
        }
		.layui-upload-img-container{
        	position: relative;
        }
        .layui-upload-img {
		    width: 92px;
		    height: 92px;
		    margin: 10px;
		}
		.layui-upload-img-del{
			position: absolute;
			right: 0;
			top: -50px;
			font-size:24px;
		}
		.layui-table-cell, .layui-table-tool-panel li {
		     overflow: auto; 
		    /* text-overflow: ellipsis; */
		    white-space: normal; 
		}
    </style>
</head>
<body class="childrenBody">
<form class="layui-form" >
    <input value="${mallPSku.id}" name="id" type="hidden">
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  货品</label>
        <div class="layui-input-block">
			<input  type="hidden" readonly  class="layui-input" value="${mallPSku.spuId}" id="spuId" name="spuId" lay-verify="required" >
            <input  type="text" readonly ts-selected="${mallPSku.spuId}" value="${spuName}" class="layui-input"  id="spuName" name="spuName" lay-verify="required" placeholder="请选择货品">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  SKU编号</label>
        <div class="layui-input-block">
                <input  type="text" readonly class="layui-input" value = "${mallPSku.skuno}" name="skuno" lay-verify="required" placeholder="请输入SKU编号">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  SKU名称</label>
        <div class="layui-input-block">
                <input  type="text" readonly class="layui-input" value = "${mallPSku.name}" name="name" lay-verify="required" placeholder="请输入SKU名称">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="required">*</span> 成本价</label>
        <div class="layui-input-inline">
                <input  type="number" readonly class="layui-input" lay-verify="required"  value = "${mallPSku.priceCost}" name="priceCost"  placeholder="请输入成本价">
        </div>
        <div class="layui-form-mid layui-word-aux">元</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  销售价</label>
        <div class="layui-input-inline">
                <input  type="number" readonly class="layui-input" value = "${mallPSku.priceSale}" name="priceSale" lay-verify="required" placeholder="请输入销售价">
        </div>
        <div class="layui-form-mid layui-word-aux">元</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> 划线价格</label>
        <div class="layui-input-inline">

            <input readonly type="number"  class="layui-input" name="priceDel" value = "${mallPSku.priceDel}" placeholder="请输入划线价格">
        </div>
        <div class="layui-form-mid layui-word-aux">元</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  推荐</label>
        <div class="layui-input-inline">
			<input type="checkbox" disabled <#if mallPSku.isrec>checked</#if> name="isrec" lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
        </div>
    </div>
     <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  属性</label>
        <div class="layui-input-block">
            <div id="attrName" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">服务保障</label>
        <div class="layui-input-block">
            <div id="serviceName" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  主图</label>
        <div class="layui-input-block">
                <input type="hidden" class="layui-input" name="thumbnail" id="thumbnail" value="${mallPSku.thumbnail}" >
                <div class="layui-upload">
                    <div class="layui-upload-list">
                        <img  style="width:80px;height:80px;"  class="layui-upload-img" id="demo_thumbnail" <#if (mallPSku.thumbnail??)>src="${mallPSku.thumbnail}"</#if> >
                        <p id="demoText_thumbnail"></p>
                    </div>
                </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  介绍图</label>
        <div class="layui-input-block">

            <input type="hidden" class="layui-input" name="imgs" id="imgs" >
            <div class="layui-upload">
                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
				    <div class="layui-upload-list" id="demo2"></div>
				 </blockquote>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
             <button class="layui-btn layui-btn-primary" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name)); ">关闭</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
<script type="text/javascript" src="${base}/static/layui/xm-select.js"></script>
<script>
    layui.config({
		base : "${base}/static/layui/lay/mymodules/"
	}).use(['form','jquery','layer','upload','tableSelect'],function(){
        var form      = layui.form,
                $     = layui.jquery,
                layer = layui.layer;

      //商品属性
        var xmSelectInstanceGoods;
        $.get('${base}${adminPrefix}/mall-pattr/xmSelectData',{skuId:'${mallPSku.id}'},function(ajaxdata){
        	//console.log(ajaxdata)
        	xmSelectInstanceGoods = xmSelect.render({
	        	el: '#attrName', 
	        	autoRow: true,
	        	filterable: true,
	        	disabled:true,
	        	tree: {
	        		show: false,
	        		showFolderIcon: true,
	        		showLine: true,
	        		indent: 20,
	        		expandedKeys: [ -3 ],
	        	},
	        	toolbar: {
	        		show: true,
	        		list: ['ALL', 'REVERSE', 'CLEAR']
	        	},
	        	filterable: true,
	        	height: 'auto',
	        	on: function(data){
	        		//console.log(data)
	        		/* if(data.isAdd) {
		        		var arr = data.change;
		        		for(var k=0;k<arr.length;k++) {
		        			console.log(arr[k].__node.parent.name)
		        			arr[k].name = arr[k].__node.parent.name +'/'+ arr[k].name
		        		}
		        		//return data;
	        		}  */
	        	},
	        	data:ajaxdata
	        })
        })
        
        //服务保障
        var xmSelectInstanceService ;
         $.get('${base}${adminPrefix}/mall-pservice/xmSelectData',{skuId:'${mallPSku.id}'},function(ajaxdata){
        	//console.log(ajaxdata)
        	xmSelectInstanceService = xmSelect.render({
	        	el: '#serviceName', 
	        	autoRow: true,
	        	filterable: true,
	        	disabled:true,
	        	tree: {
	        		show: false,
	        		showFolderIcon: true,
	        		showLine: true,
	        		indent: 20,
	        		expandedKeys: [ -3 ],
	        	},
	        	toolbar: {
	        		show: true,
	        		list: ['ALL', 'REVERSE', 'CLEAR']
	        	},
	        	filterable: true,
	        	height: 'auto',
	        	on: function(data){
	        		//console.log(data)
	        	},
	        	data:ajaxdata
	        })
        })
        
        
        //初始化介绍图片
        var imgsJson = '${mallPSku.imgs}';
        if(imgsJson!='' && imgsJson!='null') {
        	var imgs = JSON.parse(imgsJson);
        	for(var k=0;k<imgs.length;k++) {
        		 $('#demo2').append('<span class="layui-upload-img-container">'+
                         '<img  src="'+ imgs[k] +'" class="layui-upload-img">'+
                         '<i class="layui-icon layui-upload-img-del" style="display:none;">&#x1007;</i><span>')
        	}
        }

    });
</script>
</body>
</html>